import { isPhone, validateIsemail } from '@fl/utils/validate'
import { reactive } from 'vue'

export function useRule() {
    const validatorShoujhm = (rule, value, callback) => {
        if (!isPhone(value))
            callback(new Error('请输入正确的手机号'))
        else callback()
    }

    const rules = reactive<any>({
        avatar: [
            { message: '请上传', required: true, trigger: 'blur' },
        ],
        // deptId: [
        //     { message: '请选择', required: true, trigger: 'blur' },
        // ],
        email: [
            { required: true, trigger: 'blur', validator: validateIsemail },
        ],
        enterpriseAccount: [
            { message: '请输入', required: true, trigger: 'blur' },
        ],
        newRoleId: [
            { message: '请选择', required: true, trigger: 'blur' },
        ],
        phonenumber: [
            { required: true, trigger: 'blur', validator: validatorShoujhm },
        ],
        userName: [
            { message: '请输入', required: true, trigger: 'blur' },
        ],
    })

    return { rules }
}
